<template>
  <div class="homepage_main">
    <div class="homepage_left">
      <span>近期比赛</span>

      <div class="slide" v-on:mouseover="stop()" v-on:mouseout="move()">
        <transition-group tag="ul" name="image">
          <li
            v-for="(item, index) in imgArray"
            v-show="index === mark"
            :key="item.id"
          >
            <img :src="item.img" alt="" />
          </li>
        </transition-group>
        <div class="bar">
          <span
            @click="change(index)"
            v-for="(item, index) in imgArray"
            :class="{ active: index === mark }"
            :key="item.id"
          ></span>
        </div>
        <div class="Switch_pictures">
          <button
            class="left_button el-icon-d-arrow-left"
            @click="btn(true)"
          ></button>
          <button
            class="right_button el-icon-d-arrow-right"
            @click="btn(false)"
          ></button>
        </div>
      </div>

      <span>社区动态</span>
      <div class="homepage_Community_dynamics">
        <div
          class="Community_dynamics_item"
          v-for="item in Community_information"
          :key="item.id"
        >
          <img :src="item.imgurl" alt="" />
          <div>
            <p>{{ item.title }}</p>
            <p>{{ item.content }}</p>
            <p>{{ item.time }}</p>
          </div>
        </div>
      </div>
    </div>
    <div class="homepage_right">
      <div class="home_agency">
        <div>
          <i class="el-icon-time"> </i>
          <span>待办</span>
          <div class="el-icon-d-arrow-right"></div>
        </div>
        <div class="home_agency_item">
          <div v-for="item in agency" :key="item.id">
            <span>{{ item.title }}</span>
            <span>{{ item.time }}</span>
          </div>
        </div>
      </div>
      <div class="home_news">
        <div>
          <i class="el-icon-chat-dot-square"> </i>
          <span>我的消息</span>
        </div>
        <div class="home_news_item">
          <p v-for="item in news" :key="item.id">
            <span>{{ item.time }}</span>
            <span>{{ item.content }}</span>
          </p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {},
  components: {},
  data() {
    return {
      statue: false,
      mark: 0,
      timer: null,
      left: "<",
      imgArray: [
        { id: 1, img: require("../../assets/Homepage-picture/img1.png") },
        { id: 2, img: require("../../assets/Homepage-picture/img2.png") },
        { id: 3, img: require("../../assets/Homepage-picture/img3.png") },
        { id: 4, img: require("../../assets/Homepage-picture/img4.png") },
        { id: 5, img: require("../../assets/Homepage-picture/img5.png") },
      ],

      Community_information: [
        {
          id: 1,
          title: "标题",
          content:
            "快乐团队获得泰迪杯一等奖这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介",
          imgurl: require("../../assets/community/img1.png"),
          time: "昨天",
        },
        {
          id: 2,
          title: "标题",
          content:
            "快乐团队获得泰迪杯一等奖这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介",
          imgurl: require("../../assets/community/img1.png"),
          time: "昨天",
        },
        {
          id: 3,
          title: "标题",
          content:
            "快乐团队获得泰迪杯一等奖这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介",
          imgurl: require("../../assets/community/img1.png"),
          time: "昨天",
        },
        {
          id: 4,
          title: "标题",
          content:
            "快乐团队获得泰迪杯一等奖这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介这是内容简介",
          imgurl: require("../../assets/community/img1.png"),
          time: "昨天",
        },
      ],
      agency: [
        { id: 1, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 2, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 3, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 4, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 5, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 6, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 7, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 8, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 9, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 10, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 11, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 12, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 13, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 14, title: "您未签署项目协议书", time: "2022-4-25" },
        { id: 15, title: "您未签署项目协议书", time: "2022-4-25" },
      ],

      news: [
        {
          id: 1,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 2,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 3,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 4,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 5,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 6,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 7,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 8,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 9,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 10,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 11,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 12,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
        {
          id: 13,
          time: "2022-4-24  14:20:30",
          content: "您的入驻申请已审核通过！",
        },
      ],
    };
  },
  methods: {
    torouter(address) {
      this.$router.push(address);
    },
    autoPlay() {
      this.mark++;
      if (this.mark === 5) {
        //当遍历到最后一张图片置零
        this.mark = 0;
      }
    },
    play() {
      this.timer = window.setInterval(this.autoPlay, 3000);
    },
    change(i) {
      this.mark = i;
    },

    stop() {
      window.clearInterval(this.timer);
    },
    move() {
      this.timer = setInterval(this.autoPlay, 3000);
    },

    btn(bot) {
      if (bot == true) {
        this.mark -= 1;
        if (this.mark == -1) {
          //当遍历到最后一张图片置零
          this.mark = 4;
        }
      } else {
        this.mark += 1;
        if (this.mark === 5) {
          //当遍历到最后一张图片置零
          this.mark = 0;
        }
      }
    },
  },
  created() {
    this.play();
  },
};
</script>

<style lang="less" >
.homepage_main {
  height: 100%;
  width: 98%;

  display: flex;
  overflow: hidden;
}
.homepage_left {
  overflow: auto;

  width: 70%;
  margin: 10px 0px 0px 30px;
  height: 97%;
  // background-color: red;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  span {
    height: 7%;
    font-size: 25px;
    margin: 10px 0px 0px 20px;
    font-weight: bold;
  }
  padding: 10px;
}

.homepage_left::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: rgb(255, 255, 255);
}
.homepage_left::-webkit-scrollbar {
  width: 6px;
}
//左页面的滚动条
.homepage_left:hover::-webkit-scrollbar-thumb {
   background: rgba(0, 0, 0, 0.2);
}

.slide {
  margin: 15px;
  height: 600px;
  width: 99%;

  overflow: hidden;
  position: relative;

  ul {
    padding: 0px;
    margin: 0px;
    height: 100%;
    width: 100%;
  }
  img {
    height: 100%;
    width: 100%;

    border-radius: 10px;
  }
  li {
    height: 100%;
    width: 100%;
    position: absolute;
  }
}
.slide:hover {
  button {
    display: block;
  }
}

.bar {
  position: absolute;
  width: 100%;
  bottom: 10px;
  margin: 0 auto;
  z-index: 10;
  text-align: center;

  cursor: pointer;
  span {
    width: 20px;
    height: 20px;
    border-radius: 10px;
    border: none;
    background: white;
    display: inline-block;
    margin-right: 10px;
  }
  .active {
    background: rgb(104, 103, 103) !important;
  }
}

.Switch_pictures {
  position: absolute;
  width: 100%;
  bottom: 10px;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  height: 100px;
  top: 45%;
  .left_button {
    font-size: 70px;
    color: rgb(215, 215, 215);

    border: none;

    background-color: transparent;
    cursor: pointer;
    display: none;
  }
  .right_button {
    display: none;
    font-size: 70px;
    color: rgb(215, 215, 215);
    border: none;

    // border-radius: 100px 0 0 100px;
    background-color: transparent;

    cursor: pointer;
    // background-color: rgb(219, 15, 15);
  }
}
.image-enter-active {
  opacity: 1;
  transition: all 1.5s ease;
}
.image-enter-leave {
  opacity: 0.6;
  transition: all 1.5s ease;
}
.image-enter {
  opacity: 0.5;
}
.image-leave {
  opacity: 1;
}

.homepage_Community_dynamics {
  // height: 500px;
  display: flex;
  flex-direction: column;
  height: 50%;

  .Community_dynamics_item {
    margin-top: 20px;
    margin-left: 16px;
    height: 120px;
    // border-bottom: 1px solid red;
    width: 95%;
    display: flex;
    flex-direction: row;
    // padding: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12), 0 0 10px rgba(0, 0, 0, 0.04);

    img {
      height: 120px;
      width: 160px;
    }
    div {
      display: flex;
      flex-direction: column;
      margin-left: 10px;

      p:nth-child(1) {
        height: 20px;
        font-size: 20px;
        margin: 0px;
      }
      p:nth-child(2) {
        height: 60px;
        margin: 0px;
        padding: 0px;
        margin-top: 10px;
      }
      p:nth-child(3) {
        padding-left: 95%;
        height: 20px;
        margin: 0px;
        margin-top: 10px;
      }
    }
  }
}

.homepage_right {
  // height:500px;
  height: 100%;
  width: 36%;
  margin: 10px 20px 0px 10px;
  // border: 1px solid red;
}
.home_agency,
.home_news {
  height: 40%;

  width: 90%;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.12), 0 0 10px rgba(0, 0, 0, 0.04);
  border-radius: 10px;
  padding: 20px 40px 10px 40px;
}

.home_agency {
  display: flex;
  flex-direction: column;
  div:nth-child(1) {
    display: flex;
    flex-direction: row;
    height: 10%;
    width: 100%;
    border-bottom: 1px solid rgb(229, 229, 229);
    padding-bottom: 10px;
    i {
      color: rgb(82, 146, 192);
      font-size: 40px;
    }
    span {
      margin-left: 20px;
      height: 40px;
      line-height: 40px;
      font-weight: bold;
      font-size: 20px;
      width: 200px;
      // display:block;
      word-break: keep-all;
    }
    div {
      margin-left: 70%;
      font-size: 32px;
      height: 40px;
      line-height: 40px;
      color: rgb(215, 215, 215);
    }
  }
  .home_agency_item {
    // margin: 10px;
    overflow-y: auto;
    height: 80%;
    display: flex;
    flex-direction: column;
    div {
      margin: 0px;
      padding: 0px;
      border-bottom: 1px solid rgb(215, 215, 215);
      width: 95%;
      height: 60px;
      display: flex;
      justify-content: space-between;
      span {
        height: 60px;
        line-height: 60px;
        width: auto;
        margin: 0px;
        font-size: 15px;
        font-weight: normal;
      }
      span:nth-child(2) {
        // margin-left: 20%;
        color: rgb(127, 127, 127);
      }
    }
  }
}

.home_news {
  margin-top: 14%;
  div:nth-child(1) {
    display: flex;
    flex-direction: row;
    height: 50px;
    width: 100%;
    border-bottom: 1px solid rgb(229, 229, 229);

    i {
      color: rgb(82, 146, 192);
      font-size: 40px;
    }
    span {
      margin-left: 20px;
      height: 40px;
      line-height: 40px;
      font-weight: bold;
      font-size: 20px;
      width: 200px;
      // display:block;
      word-break: keep-all;
    }
  }
}

.home_news_item {
  height: 80%;
  overflow-y: scroll;
  display: flex;
  flex-direction: column;
  margin: 10px 0px 10px 0px;

  p {
    margin: 0px;
    padding: 0px;
    height: 50px;
    border-left: 2px solid rgb(153, 197, 255);
    display: flex;
    flex-direction: column;
    justify-content: space-between;

    span:nth-child(1) {
      width: auto;
      margin: 0px;
      height: 10px;
      font-size: 15px;
      font-weight: normal;
      color: rgb(127, 127, 127);
      margin-left: 30px;
    }
    span:nth-child(2) {
      height: 50px;
      margin-left: 50px;
      width: auto;
      margin-top: 0px;
      font-size: 15px;
      font-weight: normal;

      line-height: 50px;
    }
  }
}
.home_news_item::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: #fff;
}
.home_news_item::-webkit-scrollbar {
  width: 6px;
}

.home_news_item:hover::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
}
.home_agency_item::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: #fff;
}
.home_agency_item::-webkit-scrollbar {
  width: 6px;
}

.home_agency_item:hover::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
}
</style>